
#MAKEFILE FOR LONG-TERM CARE INSURANCE AND THE FAMILY
#CORINA MOMMAERTS

objects = main.o params.o normcdf.o searchnew.o states.o utilityfs.o wage.o grids.o valuefunction.o predata.o simulate.o simwrite.o
compiler_name = mpif90
include_path = -I ../../install/include 
library_path = -L ../../install/lib
switch = -finit-local-zero -fbounds-check -fbacktrace -fopenmp

my_program: $(objects)
	$(compiler_name) -o my_program $(switch) $(objects) $(library_path)

params.mod: params.o params.f90
	$(compiler_name) -c $(switch) params.f90

params.o: params.f90
	$(compiler_name) -c $(switch) params.f90

normcdf.mod: normcdf.o normcdf.f90
	$(compiler_name) -c $(switch) normcdf.f90

normcdf.o: normcdf.f90
	$(compiler_name) -c $(switch) normcdf.f90

searchnew.mod: params.mod searchnew.o searchnew.f90
	$(compiler_name) -c $(switch) searchnew.f90

searchnew.o: params.mod searchnew.f90
	$(compiler_name) -c $(switch) searchnew.f90

states.mod: params.mod states.o states.f90
	$(compiler_name) -c $(switch) states.f90

states.o: params.mod states.f90
	$(compiler_name) -c $(switch) states.f90

utilityfs.mod: params.mod utilityfs.o utilityfs.f90
	$(compiler_name) -c $(switch) utilityfs.f90

utilityfs.o: params.mod utilityfs.f90
	$(compiler_name) -c $(switch) utilityfs.f90

wage.mod: params.mod normcdf.mod wage.o wage.f90
	$(compiler_name) -c $(switch) wage.f90

wage.o: params.mod normcdf.mod wage.f90
	$(compiler_name) -c $(switch) wage.f90
	
grids.mod: params.mod states.mod wage.mod grids.o grids.f90
	$(compiler_name) -c $(switch) grids.f90

grids.o: params.mod states.mod wage.mod grids.f90
	$(compiler_name) -c $(switch) grids.f90

valuefunction.mod: params.mod states.mod searchnew.mod wage.mod utilityfs.mod valuefunction.o valuefunction.f90
	$(compiler_name) -c $(switch) valuefunction.f90

valuefunction.o: params.mod states.mod searchnew.mod wage.mod utilityfs.mod valuefunction.f90
	$(compiler_name) -c $(switch) valuefunction.f90

predata.mod: params.mod predata.o predata.f90
	$(compiler_name) -c $(switch) predata.f90

predata.o: params.mod predata.f90
	$(compiler_name) -c $(switch) predata.f90

simulate.mod: params.mod states.mod searchnew.mod utilityfs.mod wage.mod grids.mod simulate.o simulate.f90
	$(compiler_name) -c $(switch) simulate.f90

simulate.o: params.mod states.mod searchnew.mod utilityfs.mod wage.mod grids.mod simulate.f90
	$(compiler_name) -c $(switch) simulate.f90

simwrite.mod: params.mod simulate.mod simwrite.o simwrite.f90
	$(compiler_name) -c $(switch) simwrite.f90

simwrite.o: params.mod simulate.mod simwrite.f90
	$(compiler_name) -c $(switch) simwrite.f90

main.o: grids.mod valuefunction.mod params.mod predata.mod simulate.mod simwrite.mod states.mod utilityfs.mod wage.mod main.f90
	$(compiler_name) $(include_path) -c $(switch) main.f90

clean:
	rm *.o *.mod